﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
namespace BBS.Bll.Security
{
    class MD5
    {
        private MD5(){}

        public static string GetMd5Hash(string input)
        {
            var m5 = System.Security.Cryptography.MD5.Create();
            var data = m5.ComputeHash(Encoding.Default.GetBytes(input));
            StringBuilder sb = new StringBuilder();
            foreach (byte b in data)
            {
                sb.Append(b.ToString("x2"));
            }
            return sb.ToString();
        }

        public static bool VerifyMd5Hash(string source,string hash)
        {
            return GetMd5Hash(source) == hash;
        }
    }
}
